<template>
    <section class="content-box">
    	<div>
        <!--工具条-->
        <el-col class="toolbar">
            <el-col :span="18">
                <h2>期初余额</h2>
            </el-col>
            <el-col :span="6">
                <el-form :inline="true"> 
                    <!-- :model="filters"> -->
                    <!-- <el-form-item>
                        <el-input v-model="filters.name" placeholder="请输入查询项"></el-input>
                    </el-form-item> -->
                    <!-- <el-form-item>
                        <el-button type="primary" class="el-icon-search" v-on:click="handleFilterd"> 查询</el-button>
                    </el-form-item> -->
                        <el-button type="primary" class="el-icon-search" @click="CheckAll" :disabled="CheckSta"> 审核</el-button>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" class="el-icon-search" @click="CancelAudit" :disabled="CancelSta"> 取消审核</el-button>
                    </el-form-item>
                    <el-form-item>
                    <label for="file" class="label-file" :disabled="CheckSta">导入</label>
                    <input name="file" id="file" type="file" accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" @change="update" >
                    </el-form-item>
                </el-form>
            </el-col>
        </el-col>
        <!--列表-->
        <el-table :data="tableData" max-height="700" border highlight-current-row style="width: 83.8%">
            <el-table-column prop="Init_AccountItem" label="会计科目编码" header-align="center" width="150">
            </el-table-column>
            <el-table-column prop="AccountItemName" label="会计科目" header-align="center" width="300">
            </el-table-column>
            <el-table-column prop="Init_BeginPeriodBalanceJie" label="期初借方" :formatter="dealF" header-align="center"  align="right" width="150">
            </el-table-column>
            <el-table-column prop="Init_BeginPeriodBalanceDai" label="期初贷方" :formatter="dealF" header-align="center"  align="right" width="150">
            </el-table-column>
            <el-table-column prop="Init_BeginYearBalanceJie" label="年初借方" :formatter="dealF" header-align="center"  align="right" width="150">
            </el-table-column>
            <el-table-column prop="Init_BeginYearBalanceDai" label="年初贷方" :formatter="dealF" header-align="center"  align="right" width="150">
            </el-table-column>
            <el-table-column prop="Init_TotalJie" label="累计借方" :formatter="dealF" header-align="center"  align="right" width="150"> 
            </el-table-column>
            <el-table-column prop="Init_TotalDai" label="累计贷方" :formatter="dealF" header-align="center"  align="right" width="150">
            </el-table-column>
        </el-table>
		</div>
    </section>
</template>
<script>
import axios from '../../../util/axios';
import qs from 'qs';
export default {
    name: 'keeper',
    data() {
        return {
            tableData: [],//数据列表
            formLabelWidth: '120px',//input输入框宽度
            total: 0, //数据总数
            rows: 10000000, //每页显示多少条
            currentPage: 1,//当前页数
            // filters: { //查询项
            //     name: '',
            // },
            Requestdata:'',//内容
            ListState:'',//列表状态值
            gaListSta:'',//列表状态值
            CheckSta:true,
            CancelSta:true,
           
        }
    },
    methods: {
 //    pproveLode    上传接口 
         update(e){
          let file = e.target.files[0];           
          let param = new FormData(); //创建form对象
          param.append('file',file,file.name);//通过append向form对象添加数据
          param.append('chunk','0');//添加form表单中其他数据
          console.log(param.get('file')); //FormData私有类对象，访问不到，可以通过get判断值是否传进去
          let config = {
            headers:{'Content-Type':'multipart/form-data'}
          };  //添加请求头
          axios.post('pproveLode',param,config)
          .then(response=>{
            console.log(response.data);
          })        
        },

        CancelAudit(){//审核功能键
             axios.post("Caudit").then(data => {
               console.log(data)
               this.$message({
            message: data.Message
          });
               this.getList();
            }).catch(err => {
              console.log(err)
               this.$message({
            message: data.Message
          });  
            })
        },
        //审核接口  ProveAudit
        CheckAll(){//审核
             axios.post("ProveAudit").then(data => {
               console.log(data)
               this.$message({
            message: data.Message
          });
               this.getList();
            }).catch(err => {
              console.log(err)
               this.$message({
            message: data.Message
          });  
            })
        },
        handlePreview(file, fileList) {
        console.log(file, fileList);
      },
        changePage(page) {
            this.currentPage = page;
            this.getList();
        },
        
        getList: function() {     
            axios.post("getBalanceList",{
                page: this.currentPage,  //当前页数， 
                rows: this.rows, // 每页多少条
            }).then(data => {
                console.log('总列表',data)
                this.total = data.total;
                this.tableData = data.rows; //客户列表渲染到表格上
                this.ListState = data.vaStatus;//列表控制状态（审核）
                this.gaListSta = data.gaStatus;//列表控制状态1
                console.log('vaStatus',this.ListState);
                console.log('gaStatus',this.gaListSta);
            if(this.ListState==0){this.CancelSta=true}else{
                this.CheckSta = false
            };
            if(this.gaListSta==1){ this.CheckSta=true}else{
                this.CheckSta=false
            }
            }).catch(err => {
                console.log(err);
            })
        },
        dealF(e,cell,cellValue) {
				console.log("1111111",cellValue)
				if(cellValue == 0){
					return ''
				}else{
					return cellValue
				}	   
			},
        /**
         * 查询项
         */
        // handleFilterd() {
        //     var filterName = { "groupOp": "OR", "rules": [{ "field": "Init_AccountItem", "op": "cn", "data": this.filters.name }, { "field": "AccountItemName", "op": "cn", "data": this.filters.name }], "groups": [] };
        //     axios.post("getBalanceList", { filter: JSON.stringify(filterName) }).then(data => {
        //         this.tableData = data.rows;
        //         console.log(123);
        //     }).catch(err => {
        //         console.log(err);
        //     })
        // },

    },
    mounted() {
        this.getList();//初始化页面时候就要率先执行获取列表类型接口
    }
}
</script>
<style scoped lang="scss">
@import '../../../common/css/index.css';
</style>